<?php
    require_once '../Tool/Common/PrepareInput.php';

    session_start();
    if (empty($_SESSION["userType"])) {
        $url="../Index.php";
        include_once '../Tool/Common/Redirect.php';
        exit();
    }

    if($_SESSION["userType"]=="Therapy Assistant"){
        $url="../Index.php";
        include_once '../Tool/Common/Redirect.php';
        exit();
    }
    
    $UpdateActivityId=$UpdateActivityName=$UpdateCategory=$UpdateCentreName="";  

    if(isset($_REQUEST['UpdateActivityId'])){ 
        $UpdateActivityId=prepareInput($_REQUEST['UpdateActivityId']); 
    }
    if(isset($_REQUEST['UpdateActivityName'])){ 
        $UpdateActivityName=prepareInput($_REQUEST['UpdateActivityName']); 
    }
    if(isset($_REQUEST['UpdateCategory'])) { 
        $UpdateCategory=prepareInput($_REQUEST['UpdateCategory']); 
    }
    if(isset($_REQUEST['UpdateCentreName'])) { 
        $UpdateCentreName=prepareInput($_REQUEST['UpdateCentreName']); 
    }

    $result=array();

    $result['flagActivityId']=0;  
    $result['flagActivityName']=0;  
    $result['flagCategory']=0;
    $result['flagCentreName']=0;

    if(preg_match("/^[0-9]*$/",$UpdateActivityId)&&!empty($UpdateActivityId)){
        $result['flagActivityId']=1;
    }
    if(preg_match("/^[A-Za-z0-9() ]*$/",$UpdateActivityName)&&!empty($UpdateActivityName)){
        $result['flagActivityName']=1;
    }
    if(preg_match("/^[A-Za-z0-9 ]*$/",$UpdateCategory)&&!empty($UpdateCategory)){
        $result['flagCategory']=1;
    }
    if(preg_match("/^[A-Za-z0-9() ]*$/",$UpdateCentreName)&&!empty($UpdateCentreName)){
        $result['flagCentreName']=1;
    }

    echo json_encode($result);
?>